package com.codegen.enums;


import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import lombok.Getter;
import lombok.ToString;

import java.util.Date;

/**
 * @author LZCXTECH06
 * @date 2019年8月28日
 */
@Getter
@ToString
@JsonFormat(shape = Shape.OBJECT)
public enum FieldType {

    /**
     * 
     */
    VARCHAR(String.class, true, false),
    /**
     * 
     */
    CHAR(String.class, true, false),
    /**
     * 
     */
    TEXT(String.class, false, false),
    /**
     * 
     */
    BIT(Boolean.class, true, false),

    /**
     * 
     */
    TINYINT(Integer.class, true, false),
    /**
    * 
    */
    INT(Integer.class, true, false),

    /**
    * 
    */
    BIGINT(Long.class, true, false),

    /**
    * 
    */
    FLOAT(Float.class, true, true),

    /**
    * 
    */
    DOUBLE(Double.class, true, true),

    /**
     * 精度类型
     */
    DECIMAL(Double.class, true, true),

    /**
     * 时间
     */
    DATETIME(Date.class, false, false);

    /**
     * 
     */
    FieldType(Class<?> clz, boolean lengthable, boolean decimalable) {
        this.javaClass = clz;
        this.lengthable = lengthable;
        this.decimalable = decimalable;
    }

    private Class<?> javaClass;

    private boolean lengthable;

    private boolean decimalable;

    public String getClassName() {
        return javaClass.getSimpleName();
    }

    public String getName() {
        return this.name();
    }
}
